package com.tony.demo;

import android.app.Application;
import android.content.Context;
import android.content.Intent;
import android.text.TextUtils;

import com.puhui.lib.http.HttpUtils;
import com.puhui.lib.http.RequestMethod;
import com.puhui.lib.utils.AppInfoUtils;
import com.puhui.lib.utils.DMLog;

import androidx.multidex.MultiDex;

/**
 * Copyright:
 * Created by TangJian on 2019/4/17.
 * Description:
 * Modified:
 */

public class DemoApplication extends Application {
    private static DemoApplication instance;
    public long diffTime;
    private Intent location;

    @Override
    public void onCreate() {
        super.onCreate();
        instance = this;

        DMLog.e(this.getClass().getCanonicalName(), new StringBuilder("onCreate被执行了  进程号：")
                .append(AppInfoUtils.getProcessName(this)).toString());

        StringBuilder stringBuilder = new StringBuilder(BuildConfig.APPLICATION_ID).append(":location");
        if (!TextUtils.equals(stringBuilder.toString(), AppInfoUtils.getProcessName(this))) {
            //只在主进程中初始化
            HttpUtils.newInstance().requestMethod(RequestMethod.OK_HTTP_RETROFIT);
//            CrashHandler.getInstance().init(this);

//            location = new Intent(this, LocationService.class);
//            startService(location);
        }
    }

    @Override
    protected void attachBaseContext(Context base) {
        super.attachBaseContext(base);
        MultiDex.install(base);
    }

    public static DemoApplication getInstance() {
        return instance;
    }

    public Intent getLocation() {
        return location;
    }
}
